#include <iostream>
#include <cstring>

#define ANIMAL_COUNT 2

using namespace std;

class Animal {
	protected:
		char *m_name;
	public:
		Animal(const char *name);
		~Animal();
		virtual void makeSound() = 0; // 纯虚函数，不用纯虚函数的话一定要加实现
};

Animal::Animal(const char *name)
{
	m_name = new char[strlen(name) + 1];
	strcpy(m_name, name);
}

Animal::~Animal()
{
	delete m_name;
}

class Dog : public Animal {
	public:
		Dog(const char *name) : Animal(name) { }
		virtual void makeSound() { cout << m_name << "：汪汪汪！" << endl; }
};

class Cat : public Animal {
	public:
		Cat(const char *name) : Animal(name) { }
		virtual void makeSound() { cout << m_name << "：喵喵喵！" << endl; }
};
 
int main(void)
{
	int i;
	Animal *animals[ANIMAL_COUNT];

	animals[0] = new Cat("猫大橘");
	animals[1] = new Dog("狗小灰");

	for (i = 0; i < ANIMAL_COUNT; i++) {
		animals[i]->makeSound();
	}

	return 0;
}
